<template>
    <div style="width:100%">
        <h3>添加商品</h3>
        商品名称<el-input v-model="name" class="myinputcss" placeholder="请输入内容"></el-input><br>
        商品价格<el-input v-model="price" class="myinputcss" placeholder="请输入内容"></el-input><br>
        店铺名称<el-input v-model="shop" class="myinputcss" placeholder="请输入内容"></el-input><br>
        商品描述<el-input v-model="describe" class="myinputcss" placeholder="请输入内容"></el-input><br>
        商品数量<el-input v-model="number" class="myinputcss" placeholder="请输入内容"></el-input><br>
        商品类型<el-input v-model="type" class="myinputcss" placeholder="请输入内容"></el-input><br>
        图片地址<el-input v-model="src" class="myinputcss" placeholder="请输入内容"></el-input><br>
        <el-button v-on:click="add" class="mybuttoncss" type="primary">上传<i class="el-icon-upload el-icon--right"></i></el-button>
    </div>
</template>
<script>
export default {
    data(){
        return{
            name:'',
            price:'',
            shop:'',
            describe:'',
            number:0,
            type:'',
            src:''
        }
    },
    mounted:function(){

    },
    methods:{
        add(){
            let url="/api/tcb/databaseadd?access_token=38_fh29a0Eq_pUPxPPUpvK_DHK5XBNOjDKFFiNpCbMKMxPGW6MdIuzPA7pkmzXFRCdEk66cpZdqW8GlmwAl5s9r6VSGQWgQWKqip_rS-oZYSToD83cBmG2i36F4t5sUT7xKDWFUk4LWQytmjJc0YTHjAAAIDR"
            let name1="\""+this.name+"\""
            let price1=this.price
            let describe1="\""+this.describe+"\""
            let shop1="\""+this.shop+"\""
            let type1="\""+this.type+"\""
            let number1=this.number
            let src1="\""+this.src+"\""
            this.$axios.post(url,{
                "env":"minijingdong-6gmzb5oc4447b462",
                "query":"db.collection(\"Shopping\").add({data:{name:"+name1+",shop:"+shop1+",price:"+price1+",describe:"+describe1+",number:"+number1+",type:"+type1+",src:"+src1+"}})"
            }).then(()=>{
                alert("上传成功")
                // console.log(typeof(name1))
                // console.log("db.collection(\"Shopping\").add({data:{name:"+name1+",price:"+price1+",describe:"+describe1+",number:8,type:\"鞋靴\",src:\"...\"}})")
            }).catch((err)=>{
                alert("上传失败")
                console.log(err)
            })
        }
    }
}
</script>
<style scoped>
    .myinputcss{
        margin-left: 20px;
        width:70%
    }
    .mybuttoncss{
        margin-top:40px;
    }
</style>